import db from '$lib/database';

/**
 * @type {import('@sveltejs/kit').RequestHandler}
 */
export function get({ params }: { params: { slug: string } }): unknown {
	// the `slug` parameter is available because this file
	// is called [slug].json.js
	const { slug } = params;
	const article = db.has(slug);
	console.log('>>>>>>slug:', slug);

	if (article) {
		return {
			body: db.get(slug)
		};
	}
}
